<?php
function generate_cat_url($cat = array()){
    if($cat){
        return '/'.$cat['cat_name'].'-'.$cat['cat_id'].'.chn';
    }else{
        return '/san-pham/';
    }

}
function generate_news_detail_url($news){
    return '/'.removeTitle($news['cat_name']).'/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}
function generate_recruitment_detail_url($news) {
    return '/tuyen-dung/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}
function generate_promotion_detail_url($news) {
    return '/khuyen-mai/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}
function generate_technology_detail_url($news) {
    return '/goc-ky-thuat/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}
function generate_product_detail_url($product){
    if(isset($product['fac_name'])){
        $product['fac_name'] = removeTitle(mb_strtolower($product['fac_name']));
        return '/'.$product['fac_name'].'/'.removeTitle($product['pro_name']). '-prd' . $product['pro_id'] .'.html';
    }else{
        return '/san-pham/'.removeTitle($product['pro_name']). '-' . $product['pro_id'] .'.html';
    }

}
function generate_service_cat($type = '',$cat_parent_id = 0,$cat_id = 0){
    if($cat_parent_id == 0) {
        if($type){
            return '/'.$type;
        }else{
            return '/dich-vu/';
        }
    }else {
        if($cat_parent_id == 19) {
            return '/phan-cung/'.$type.'-'.$cat_id;
        }else {
            return '/phan-mem/'.$type.'-'.$cat_id;
        }
    }
}
function generate_service_detail_url($product){
    return '/dich-vu/'.removeTitle($product['pro_name']). '-' . $product['pro_id'] .'.html';
}
function generate_factory_url($factory){
    return '/'.removeTitle($factory['fac_name']).'-'.$factory['fac_id'] .'/';
}
function generate_shop_cart_list(){
    return '/gio-hang';
}
function generate_checkout_url(){
    return '/thanh-toan';
}
function generate_login_url(){
    return '/dang-nhap.html';
}
function generate_profile_url(){
    return '/thanh-vien';
}
function generate_bill_url($bil_id = 0){
    return '/hoa-don/'.($bil_id ? $bil_id : '');
}
function removeTitle($string,$keyReplace = "/"){
	 $string = removeSign($string);
	 $string  =  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  =  str_replace(" ","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
?>